Cloud Storage
順序
which are ordered in the list lexicographically by name
辞書順のみっぽい
filename の頭の / はどちらかというといらない
/hoge/fuga のファイルを書こうとすると / というディレクトリが作られる
問題なく使えるけど要らない
https://gyazo.com/0c508b57acf3dc1733dfe043208c9f81
メモリ上のデータをアップロードする
めも、バイナリにに限らず似たような感じで
code:upload_stream.ts
import { Readable } from 'stream';
import { Storage, File } from '@google-cloud/storage';
function uploadFile(
bucket: string,
path: string,
image: Buffer,
contentType: string = 'image/png'
): Promise<File> {
const file = storage.bucket(bucket).file(path);
const writer = file.createWriteStream({
metadata: { contentType },
});
const reader = new Readable();
reader.push(image);
reader.push(null);
return new Promise((resolve, reject) => {
reader
.on('error', reject)
.pipe(writer)
.on('error', reject)
.on('finish', () => resolve(file));
});
}
暗号化の話おもろい
デフォルトの暗号化でも内部では90日以下でキーのローテーションしていて最大20バージョンまで持ってる
90 * 20 / 365 = 4.9 で5年に1回は鍵のローテーションのために再暗号化される
昔のやつ、いまは Tink
バケットロック
保持ポリシーの変更や削除を防ぐ、保存期間 n 年 てきなもの守る
主にコンプライス要件への対応に使う
バケットの保持ポリシーのロックは元に戻すことができません。